/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package sysmodel.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import sysmodel.HttpMethod;
import sysmodel.RestService;
import sysmodel.RestServiceParameter;
import sysmodel.SysmodelPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Rest Service</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link sysmodel.impl.RestServiceImpl#getMethod <em>Method</em>}</li>
 *   <li>{@link sysmodel.impl.RestServiceImpl#getPath <em>Path</em>}</li>
 *   <li>{@link sysmodel.impl.RestServiceImpl#getRestParameters <em>Rest Parameters</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class RestServiceImpl extends ServiceImpl implements RestService {
	/**
	 * The default value of the '{@link #getMethod() <em>Method</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMethod()
	 * @generated
	 * @ordered
	 */
	protected static final HttpMethod METHOD_EDEFAULT = HttpMethod.GET;

	/**
	 * The cached value of the '{@link #getMethod() <em>Method</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMethod()
	 * @generated
	 * @ordered
	 */
	protected HttpMethod method = METHOD_EDEFAULT;

	/**
	 * The default value of the '{@link #getPath() <em>Path</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPath()
	 * @generated
	 * @ordered
	 */
	protected static final String PATH_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getPath() <em>Path</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPath()
	 * @generated
	 * @ordered
	 */
	protected String path = PATH_EDEFAULT;

	/**
	 * The cached value of the '{@link #getRestParameters() <em>Rest Parameters</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRestParameters()
	 * @generated
	 * @ordered
	 */
	protected EList<RestServiceParameter> restParameters;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RestServiceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SysmodelPackage.Literals.REST_SERVICE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public HttpMethod getMethod() {
		return method;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMethod(HttpMethod newMethod) {
		HttpMethod oldMethod = method;
		method = newMethod == null ? METHOD_EDEFAULT : newMethod;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SysmodelPackage.REST_SERVICE__METHOD, oldMethod, method));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getPath() {
		return path;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPath(String newPath) {
		String oldPath = path;
		path = newPath;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SysmodelPackage.REST_SERVICE__PATH, oldPath, path));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RestServiceParameter> getRestParameters() {
		if (restParameters == null) {
			restParameters = new EObjectContainmentEList<RestServiceParameter>(RestServiceParameter.class, this, SysmodelPackage.REST_SERVICE__REST_PARAMETERS);
		}
		return restParameters;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SysmodelPackage.REST_SERVICE__REST_PARAMETERS:
				return ((InternalEList<?>)getRestParameters()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SysmodelPackage.REST_SERVICE__METHOD:
				return getMethod();
			case SysmodelPackage.REST_SERVICE__PATH:
				return getPath();
			case SysmodelPackage.REST_SERVICE__REST_PARAMETERS:
				return getRestParameters();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SysmodelPackage.REST_SERVICE__METHOD:
				setMethod((HttpMethod)newValue);
				return;
			case SysmodelPackage.REST_SERVICE__PATH:
				setPath((String)newValue);
				return;
			case SysmodelPackage.REST_SERVICE__REST_PARAMETERS:
				getRestParameters().clear();
				getRestParameters().addAll((Collection<? extends RestServiceParameter>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SysmodelPackage.REST_SERVICE__METHOD:
				setMethod(METHOD_EDEFAULT);
				return;
			case SysmodelPackage.REST_SERVICE__PATH:
				setPath(PATH_EDEFAULT);
				return;
			case SysmodelPackage.REST_SERVICE__REST_PARAMETERS:
				getRestParameters().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SysmodelPackage.REST_SERVICE__METHOD:
				return method != METHOD_EDEFAULT;
			case SysmodelPackage.REST_SERVICE__PATH:
				return PATH_EDEFAULT == null ? path != null : !PATH_EDEFAULT.equals(path);
			case SysmodelPackage.REST_SERVICE__REST_PARAMETERS:
				return restParameters != null && !restParameters.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (method: ");
		result.append(method);
		result.append(", path: ");
		result.append(path);
		result.append(')');
		return result.toString();
	}

} //RestServiceImpl
